#ifndef SCANFORAUDIO_H
#define SCANFORAUDIO_H

#include <qstring.h>
#include <qthread.h>

#include "CharacterProcessor.h"

class ScanForAudio : public QThread
{
public:
   class EventInterface
   {
      typedef enum
      {
         IDLE,
         SCANNING
      } State;

      virtual ~EventInterface(){};
      virtual void ScanForAudio_Status( State state, QString& message );
   };

   ScanForAudio();
   ~ScanForAudio();

   void SetHandler( EventInterface* handler );
   void ClearHandler();

   void Start();
   int MaxCount;

   virtual void run();

private:
   void Scan();
   int  CountFiles( const QString& directory );
   void BuildFileList( const QString &directory );
   void PruneDatabase();
   void CreateDatabase();
   bool Test( const QString& filename, const QString& signature );
   void Add( const QString& filename, const QString& signature );
   QString ComputeFileSignature( const QString& path );

   QString RootPath;
   CharacterProcessor TextTransform;
   int Count;
   EventInterface*   Handler;
   QMutex            m_Mutex;
};

#endif
